home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
c
/
quikc21.zip
/
QWIKDEMO.C
< prev
next >
Wrap
Text File
|
1989-07-06
|
34KB
|
1,082 lines
/*===========================================================================*\
| QWIKDEMO.C ver 2.1, 07-06-89 |
| |
| Demo has been programmed best for color cards in 25-line mode. |
| Do not terminate this program manually. | |
| |
| Copyright (c) 1988,1989 by James H. LeMay, All rights reserved. |
| |
| Conversion to C by Jordan Gallagher / Wisdom Research |
\*===========================================================================*/
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <dos.h>
#include <math.h>
#include "qwikc21.h"
char ch;
char lastmode;
char step, colmax;
char blkrow, blkcol, v;
char numstr[80];
char coll[3], colr[3];
char saved_block[4000], popup_block[4000];
int brdrattr, wndwattr;
int i, count, fgrnd, bgrnd;
long rnum;
char strng[40]={ " Q Screen Utilities " };
char strng2[40]={ " QWIKC Screen Utilities " };
char data[9][40]=
{ "1", "22", "333", " Q Screen Utilities ", "Odd Length", "Even Length",
"18 characters wide", "19 characters width", "Margin to Margin width" };
char pc[14][80]=
{ "COMPUTERS: ADAPTERS:",
"------------------ ----------",
"IBM PC MDA",
"IBM XT CGA",
"IBM AT EGA",
"IBM PCjr MCGA",
"IBM PC Convertible VGA",
"IBM PS/2 Model 25 8514/A",
"IBM PS/2 Model 30 Hercules:",
"IBM PS/2 Model 50 HGC",
"IBM PS/2 Model 60 HGC Plus",
"IBM PS/2 Model 70 InColor",
"IBM PS/2 Model 80",
"IBM 3270 PC" };
char other[12][80]=
{ "qscrollup - Qwik scroll up",
"qscrolldown- Qwik scroll down",
"qscrtovscr - block to virtual screen",
"qvscrtoscr - virtual screen to block",
"qreadstr - reads string from screen",
"qreadchar - reads char from screen",
"qreadattr - reads attr from screen",
"qviewpage - view any video page",
"qwritepage - write to any video page",
"qwrite_sub - for arrays/partial strings",
"qfillc - a self-centering qfill",
"qattrc - a self-centering qattr" };
char crsr[12][80]=
{ "gotorc - absolute cursor position",
"wherer - absolute cursor row",
"wherec - absolute cursor column",
"setcursor - sets cursor mode",
"getcursor - gets cursor mode",
"modcursor - modifies cursor mode",
"cursor_initial - cursor at startup",
"cursor_underline - normal cursor",
"cursor_halfblock - for insert editing",
"cursor_block - for the nearsighted",
"A total of 41 utilities",
"optimizing in just 2.7k bytes or less!" };
char init[10][80]=
{ "∙ Detects dual monitor/adapters for all",
" systems listed on the previous page",
"∙ Identifies each system by name",
"∙ Gets system ID and submodel ID",
"∙ Gets CPU ID",
"∙ Sets far pointer for virtual screens",
"∙ Determines need for wait-for-retrace",
"∙ Gets screen dimensions: rows by cols",
"∙ Determines the number of video pages",
"∙ Sets 4 standard cursor shapes" };
char eoss[4][80]=
{ " ∙ qwriteeos - just like qwrite ",
" ∙ qwriteeos_sub - just like qwrite_sub ",
" ∙ qfilleos - just like qfill ",
" ∙ qattreos - just like qattr " };
int wait=400;
struct border_t {
char TL[2];
char TH[2];
char TR[2];
char LV[2];
char RV[2];
char BL[2];
char BH[2];
char BR[2];
} border = { "╔", "═", "╗", "║", "║", "╚", "═", "╝" };
char bwcolors[4]={ BLACK, LIGHTGRAY, WHITE, LIGHTGRAY_BG };
#ifndef __TURBOC__
union REGS mr;
#define disable _disable
#define enable _enable
#define random(num) (rand() % (num))
#define randomize() srand((unsigned)time(NULL))
#define textmode(m) { mr.h.ah=0; mr.h.al=m; int86(0x10,&mr,&mr); }
#endif
#ifdef __TURBOC__
#define tclock() (*(long far *)0x46CL)
#else
#define tclock() (*(long far *)(0x46CL+_z))
#endif
/******************************| check_zenith |*****************************\
Since Zenith doesn't have snow on any CGAs, turn off snow checking.
\***************************************************************************/
void check_zenith(void)
{
char tmp[10];
movedata( 0xF000u, 0x800Cu, (unsigned)(((char far *)tmp)+1),
(unsigned)((char far *)tmp), 8 );
if(qsnow && (strncmp( tmp, "ZDS CORP", 8 )) == 0) {
qsnow=0;
cardsnow=0;
}
}
/******************************| closedemo |********************************\
Exits the demo.
\***************************************************************************/
void closedemo(void)
{
if(qvideo_mode <= C40) {
#ifdef __TURBOC__
delay( wait*6 );
#else
suspend( wait*6 );
#endif
textmode( lastmode );
}
gotorc( 24, 1 );
setcursor( cursor_initial );
}
/*********************************| qbox |**********************************\
qbox is an application of QWIKC Screen Utilities. It can make fast
pop-up menus. See WNDWxx.ARC for more applications.
\***************************************************************************/
void qbox( char row, char col, char rows, char cols, int wndwattr,
int brdrattr, struct border_t *b )
{
if(rows >=2 && cols >=2) {
qwrite( row, col, brdrattr, b->TL );
qfilleos( 1, cols-2, brdrattr, b->TH[0] );
qwriteeos( brdrattr, b->TR );
qfill( row+1, col, rows-2, 1, brdrattr, b->LV[0] );
qfill( row+1, col+cols-1, rows-2, 1, brdrattr, b->RV[0] );
qwrite( row+rows-1, col, brdrattr, b->BL );
qfilleos( 1, cols-2, brdrattr, b->BH[0] );
qwriteeos( brdrattr, b->BR );
qfill( row+1, col+1, rows-2, cols-2, wndwattr, ' ' );
}
}
/********************************| waitkey |********************************\
Displays a prompt and awaits a keypress.
\***************************************************************************/
void waitkey(void)
{
qwrite( 25, crt_cols-19, SAMEATTR, "press any key ..." );
if( (ch=getch()) == 0 ) ch=getch();
else if(ch==27) {
closedemo();
exit(0);
}
}
/*******************************| clearscr |********************************\
Clears the screen using the specified attribute.
\***************************************************************************/
void clearscr( int attr )
{
qfill( 1, 1, crt_rows, crt_cols, attr, ' ' );
}
/*******************************| scatter |*********************************\
Displays random boxes on the screen.
\***************************************************************************/
void scatter( char maxrows, char leftcol, char rightcol,
char botrow, char toprow )
{
int a;
char row, col, rows, cols;
rows=random(maxrows)+1;
if(qvideo_mode <= C40) {
cols = rows + (rows >> 2);
} else {
cols = (rows << 1) + (rows >> 1 );
}
col = leftcol + random( rightcol - leftcol - cols + 2 );
row = toprow + random( botrow - toprow - rows + 2 );
if(qvideo_mode == MONO) {
a=bwcolors[ random(4) ];
} else {
fgrnd=random(16);
bgrnd=random(8);
if(bgrnd == fgrnd) ++fgrnd;
a=fgrnd + (bgrnd << 4);
}
qfill( row, col, rows, cols, a, 178 );
}
/*******************************| explode |*********************************\
Makes the screen "explode" with boxes.
\***************************